package com.s69.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.s69.entity.Student;
import com.s69.service.StudentService;
import com.s69.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.transform.Result;

@RestController

public class StudentController {
    @Autowired
    private StudentService service;

    @GetMapping("/page")
    public ResultVo getPage(String stuName, @RequestParam(defaultValue = "1") Integer pageNum) {
        Page page=service.getPage(stuName,pageNum);
        return ResultVo.success("",page);
    }

    @PostMapping("/saveOrUpdate")
    public ResultVo saveOrUpdate(@RequestBody Student student){
        service.saveOrUpdate(student);
        return ResultVo.success("操作成功",null);
    }

    @DeleteMapping("/del/{id}")
    public ResultVo del(@PathVariable Integer id){
        service.removeById(id);
        return ResultVo.success("删除roxy error: Could not proxy request /page?stuName=&pageNum=1 from localhost:8088 to http://localhost:8081 (ECONNREFUSED).成功",null);
    }



}
